﻿using System;
using System.Linq;
using CH.FourBoards.LagerWalti.FrontEnd.View;
using CH.FourBoards.LagerWalti.Service.MasterData;
using CH.FourBoards.LagerWalti.WebFrontEnd.View;
using CH.FourBoards.LagerWalti.WebFrontEnd.View.Master;

namespace CH.FourBoards.LagerWalti.WebFrontEnd
{
    public class Home : PageBase
    {
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            LoadData();
        }

        private void LoadData()
        {
            try
            {
                var service = new MasterDataService();
                CategoryCount = service.ListCategories().Count();
                ProductCount = service.ListProducts().Products.Count();
            } catch (Exception ex) {
                ShowException(ex);
            }
        }

        protected int CategoryCount { get; private set; }
        protected int ProductCount { get; private set; }

        protected string ProductListLink
        {
            get { return ApplicationRoot + new ProductList().CreateLink(); }
        }

        protected string CategoryListLink
        {
            get { return ApplicationRoot + new CategoryList().CreateLink(); }
        }

        protected string WebShopLink
        {
            get { return "http://store.freebordswitzerland.com/en/"; }
        }
    }
}